﻿using AutoMapper;
using Infrastructure.Extend;
using Infrastructure.Web;
using MyData.Dto;
using MyData.Models;
using MyDomain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyApplication
{
    public class SystemConfigApp
    {
        private ISystemConfigRepository _SystemConfigService;
        public SystemConfigApp(ISystemConfigRepository SystemConfigService)
        {

            _SystemConfigService = SystemConfigService;
        }
        public SystemConfigDto GetSystemConfigDto()
        {
            var entity = _SystemConfigService.FindEntity(Guid.Empty);
            return Mapper.Map<SystemConfig, SystemConfigDto>(entity);
        }
        public bool SaveSystemConfig(SystemConfig systemConfig)
        {
            var entity = _SystemConfigService.FindEntity(systemConfig.Id);
            entity.StartTime = systemConfig.StartTime;
            entity.EndTime = systemConfig.EndTime;
            entity.Company = systemConfig.Company;
            entity.ChargeMan = systemConfig.ChargeMan;
            entity.IsParking = systemConfig.IsParking;
            entity.LimitNum = systemConfig.LimitNum;
            entity.IsTest = systemConfig.IsTest;
            entity.OneNum = systemConfig.OneNum;
            entity.ProductNum = systemConfig.ProductNum;
            entity.RepairNum = systemConfig.RepairNum;
            entity.RunNum = systemConfig.RunNum;
            entity.SpecialNum = systemConfig.SpecialNum;
            entity.StopNum = systemConfig.StopNum;
            entity.TwoNum = systemConfig.TwoNum;
            entity.Anounce = systemConfig.Anounce;
            return _SystemConfigService.Update(entity)>0;

        }
    }
}
